package o;

import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.Arrays;
import java.util.Locale;
import o.fc.c;
import org.jsoup.UncheckedIOException;

public final class gbz {
    private final String[] ʻ;
    private int ʼ;
    private int ʽ;
    private final Reader ˊ;
    private final char[] ˋ;
    private int ˎ;
    private int ˏ;
    private int ॱ;

    public gbz(Reader reader, int i) {
        this.ʼ = -1;
        this.ʻ = new String[WXMediaMessage.TITLE_LENGTH_LIMIT];
        gbj.ˋ((Object) reader);
        gbj.ˋ(reader.markSupported());
        this.ˊ = reader;
        if (i > 32768) {
            i = 32768;
        }
        this.ˋ = new char[i];
        ॱˋ();
        if (ʻॱ()) {
            throw new UncheckedIOException("Input is binary and unsupported");
        }
    }

    public gbz(Reader reader) {
        this(reader, 32768);
    }

    public gbz(String str) {
        this(new StringReader(str), str.length());
    }

    private void ॱˋ() {
        int i = 24576;
        int i2 = this.ॱ;
        if (i2 >= this.ˎ) {
            try {
                this.ˊ.skip((long) i2);
                this.ˊ.mark(32768);
                int read = this.ˊ.read(this.ˋ);
                this.ˊ.reset();
                if (read != -1) {
                    this.ˏ = read;
                    this.ʽ = i2 + this.ʽ;
                    this.ॱ = 0;
                    this.ʼ = -1;
                    if (this.ˏ <= 24576) {
                        i = this.ˏ;
                    }
                    this.ˎ = i;
                }
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }
    }

    public int ˎ() {
        return this.ʽ + this.ॱ;
    }

    public boolean ˏ() {
        ॱˋ();
        return this.ॱ >= this.ˏ;
    }

    private boolean ॱᐝ() {
        return this.ॱ >= this.ˏ;
    }

    public char ॱ() {
        ॱˋ();
        return ॱᐝ() ? '￿' : this.ˋ[this.ॱ];
    }

    char ˊ() {
        ॱˋ();
        char c = ॱᐝ() ? '￿' : this.ˋ[this.ॱ];
        this.ॱ++;
        return c;
    }

    void ˋ() {
        if (this.ॱ < 1) {
            throw new UncheckedIOException(new IOException("No buffer left to unconsume"));
        }
        this.ॱ--;
    }

    public void ʽ() {
        this.ॱ++;
    }

    void ᐝ() {
        this.ˎ = 0;
        ॱˋ();
        this.ʼ = this.ॱ;
    }

    void ʻ() {
        if (this.ʼ == -1) {
            throw new UncheckedIOException(new IOException("Mark invalid"));
        }
        this.ॱ = this.ʼ;
    }

    int ˎ(char c) {
        ॱˋ();
        for (int i = this.ॱ; i < this.ˏ; i++) {
            if (c == this.ˋ[i]) {
                return i - this.ॱ;
            }
        }
        return -1;
    }

    int ॱ(CharSequence charSequence) {
        ॱˋ();
        char charAt = charSequence.charAt(0);
        int i = this.ॱ;
        while (i < this.ˏ) {
            if (charAt != this.ˋ[i]) {
                do {
                    i++;
                    if (i >= this.ˏ) {
                        break;
                    }
                } while (charAt != this.ˋ[i]);
            }
            int i2 = i + 1;
            int length = (charSequence.length() + i2) - 1;
            if (i < this.ˏ && length <= this.ˏ) {
                int i3 = 1;
                while (i2 < length && charSequence.charAt(i3) == this.ˋ[i2]) {
                    i2++;
                    i3++;
                }
                if (i2 == length) {
                    return i - this.ॱ;
                }
            }
            i++;
        }
        return -1;
    }

    public String ॱ(char c) {
        int ˎ = ˎ(c);
        if (ˎ == -1) {
            return ॱˊ();
        }
        String ˏ = ˏ(this.ˋ, this.ʻ, this.ॱ, ˎ);
        this.ॱ = ˎ + this.ॱ;
        return ˏ;
    }

    String ˏ(String str) {
        int ॱ = ॱ((CharSequence) str);
        if (ॱ == -1) {
            return ॱˊ();
        }
        String ˏ = ˏ(this.ˋ, this.ʻ, this.ॱ, ॱ);
        this.ॱ = ॱ + this.ॱ;
        return ˏ;
    }

    public String ˏ(char... cArr) {
        ॱˋ();
        int i = this.ॱ;
        int i2 = this.ˏ;
        char[] cArr2 = this.ˋ;
        int i3 = i;
        loop0:
        while (i3 < i2) {
            for (char c : cArr) {
                if (cArr2[i3] == c) {
                    break loop0;
                }
            }
            i3++;
        }
        this.ॱ = i3;
        if (i3 > i) {
            return ˏ(this.ˋ, this.ʻ, i, i3 - i);
        }
        return "";
    }

    String ॱ(char... cArr) {
        ॱˋ();
        int i = this.ॱ;
        int i2 = this.ˏ;
        char[] cArr2 = this.ˋ;
        int i3 = i;
        while (i3 < i2 && Arrays.binarySearch(cArr, cArr2[i3]) < 0) {
            i3++;
        }
        this.ॱ = i3;
        return this.ॱ > i ? ˏ(this.ˋ, this.ʻ, i, i3 - i) : "";
    }

    String ʼ() {
        int i = this.ॱ;
        int i2 = this.ˏ;
        char[] cArr = this.ˋ;
        int i3 = i;
        while (i3 < i2) {
            switch (cArr[i3]) {
                case '\u0000':
                case '&':
                case c.ᴵ /*60*/:
                    break;
                default:
                    i3++;
            }
            this.ॱ = i3;
            return i3 <= i ? ˏ(this.ˋ, this.ʻ, i, i3 - i) : "";
        }
        this.ॱ = i3;
        if (i3 <= i) {
        }
    }

    String ॱॱ() {
        ॱˋ();
        int i = this.ॱ;
        int i2 = this.ˏ;
        char[] cArr = this.ˋ;
        int i3 = i;
        while (i3 < i2) {
            switch (cArr[i3]) {
                case '\u0000':
                case '\t':
                case '\n':
                case '\f':
                case '\r':
                case ' ':
                case '/':
                case c.ᴵ /*60*/:
                case c.ⁱ /*62*/:
                    break;
                default:
                    i3++;
            }
            this.ॱ = i3;
            return i3 <= i ? ˏ(this.ˋ, this.ʻ, i, i3 - i) : "";
        }
        this.ॱ = i3;
        if (i3 <= i) {
        }
    }

    String ॱˊ() {
        ॱˋ();
        String ˏ = ˏ(this.ˋ, this.ʻ, this.ॱ, this.ˏ - this.ॱ);
        this.ॱ = this.ˏ;
        return ˏ;
    }

    String ˊॱ() {
        ॱˋ();
        int i = this.ॱ;
        while (this.ॱ < this.ˏ) {
            char c = this.ˋ[this.ॱ];
            if ((c < 'A' || c > 'Z') && ((c < 'a' || c > 'z') && !Character.isLetter(c))) {
                break;
            }
            this.ॱ++;
        }
        return ˏ(this.ˋ, this.ʻ, i, this.ॱ - i);
    }

    String ˋॱ() {
        ॱˋ();
        int i = this.ॱ;
        while (this.ॱ < this.ˏ) {
            char c = this.ˋ[this.ॱ];
            if ((c < 'A' || c > 'Z') && ((c < 'a' || c > 'z') && !Character.isLetter(c))) {
                break;
            }
            this.ॱ++;
        }
        while (!ॱᐝ()) {
            c = this.ˋ[this.ॱ];
            if (c < '0' || c > '9') {
                break;
            }
            this.ॱ++;
        }
        return ˏ(this.ˋ, this.ʻ, i, this.ॱ - i);
    }

    String ˏॱ() {
        ॱˋ();
        int i = this.ॱ;
        while (this.ॱ < this.ˏ) {
            char c = this.ˋ[this.ॱ];
            if ((c < '0' || c > '9') && ((c < 'A' || c > 'F') && (c < 'a' || c > 'f'))) {
                break;
            }
            this.ॱ++;
        }
        return ˏ(this.ˋ, this.ʻ, i, this.ॱ - i);
    }

    String ͺ() {
        ॱˋ();
        int i = this.ॱ;
        while (this.ॱ < this.ˏ) {
            char c = this.ˋ[this.ॱ];
            if (c < '0' || c > '9') {
                break;
            }
            this.ॱ++;
        }
        return ˏ(this.ˋ, this.ʻ, i, this.ॱ - i);
    }

    boolean ˏ(char c) {
        return !ˏ() && this.ˋ[this.ॱ] == c;
    }

    boolean ˊ(String str) {
        ॱˋ();
        int length = str.length();
        if (length > this.ˏ - this.ॱ) {
            return false;
        }
        for (int i = 0; i < length; i++) {
            if (str.charAt(i) != this.ˋ[this.ॱ + i]) {
                return false;
            }
        }
        return true;
    }

    boolean ˎ(String str) {
        ॱˋ();
        int length = str.length();
        if (length > this.ˏ - this.ॱ) {
            return false;
        }
        for (int i = 0; i < length; i++) {
            if (Character.toUpperCase(str.charAt(i)) != Character.toUpperCase(this.ˋ[this.ॱ + i])) {
                return false;
            }
        }
        return true;
    }

    boolean ˋ(char... cArr) {
        if (ˏ()) {
            return false;
        }
        ॱˋ();
        char c = this.ˋ[this.ॱ];
        for (char c2 : cArr) {
            if (c2 == c) {
                return true;
            }
        }
        return false;
    }

    boolean ˊ(char[] cArr) {
        ॱˋ();
        return !ˏ() && Arrays.binarySearch(cArr, this.ˋ[this.ॱ]) >= 0;
    }

    boolean ॱˎ() {
        if (ˏ()) {
            return false;
        }
        char c = this.ˋ[this.ॱ];
        if ((c < 'A' || c > 'Z') && ((c < 'a' || c > 'z') && !Character.isLetter(c))) {
            return false;
        }
        return true;
    }

    boolean ᐝॱ() {
        if (ˏ()) {
            return false;
        }
        char c = this.ˋ[this.ॱ];
        if (c < '0' || c > '9') {
            return false;
        }
        return true;
    }

    boolean ˋ(String str) {
        ॱˋ();
        if (!ˊ(str)) {
            return false;
        }
        this.ॱ += str.length();
        return true;
    }

    boolean ॱ(String str) {
        if (!ˎ(str)) {
            return false;
        }
        this.ॱ += str.length();
        return true;
    }

    boolean ʼ(String str) {
        return ॱ(str.toLowerCase(Locale.ENGLISH)) > -1 || ॱ(str.toUpperCase(Locale.ENGLISH)) > -1;
    }

    boolean ʻॱ() {
        int i = 0;
        for (int i2 = this.ॱ; i2 < this.ˏ; i2++) {
            if (this.ˋ[i2] == '\u0000') {
                i++;
            }
        }
        if (i >= 10) {
            return true;
        }
        return false;
    }

    public String toString() {
        return new String(this.ˋ, this.ॱ, this.ˏ - this.ॱ);
    }

    private static String ˏ(char[] cArr, String[] strArr, int i, int i2) {
        int i3 = 0;
        if (i2 > 12) {
            return new String(cArr, i, i2);
        }
        if (i2 < 1) {
            return "";
        }
        int i4 = i;
        int i5 = 0;
        while (i3 < i2) {
            int i6 = i5 * 31;
            i3++;
            int i7 = i4 + 1;
            i5 = cArr[i4] + i6;
            i4 = i7;
        }
        i4 = i5 & (strArr.length - 1);
        String str = strArr[i4];
        if (str == null) {
            str = new String(cArr, i, i2);
            strArr[i4] = str;
            return str;
        } else if (ˋ(cArr, i, i2, str)) {
            return str;
        } else {
            str = new String(cArr, i, i2);
            strArr[i4] = str;
            return str;
        }
    }

    static boolean ˋ(char[] cArr, int i, int i2, String str) {
        if (i2 != str.length()) {
            return false;
        }
        int i3 = 0;
        while (true) {
            int i4 = i2 - 1;
            if (i2 == 0) {
                return true;
            }
            int i5 = i + 1;
            int i6 = i3 + 1;
            if (cArr[i] != str.charAt(i3)) {
                return false;
            }
            i3 = i6;
            i = i5;
            i2 = i4;
        }
    }
}
